package top.frsf.starter.impl;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import top.frsf.enums.GameStateEnum;
import top.frsf.object.bullet.BulletObject;
import top.frsf.panel.GamePanel;
import top.frsf.starter.Starter;

import java.awt.*;
import java.util.ArrayList;

/**
 * 子弹启动器
 *
 * @author FRSF
 * @since 2025/8/3 14:00
 */
@Data
@Slf4j
public class BulletStarter implements Starter {
    /**
     * 子弹列表
     */
    public final ArrayList<BulletObject> pesBulls = new ArrayList<>();
    /**
     * 子弹销毁列表
     */
    public final ArrayList<BulletObject> delBulls = new ArrayList<>();

    @Override
    public void init() {
        log.info("子弹启动器初始化");
    }

    @Override
    public void start(Graphics graphics) {
        if (GamePanel.state == GameStateEnum.RUNNING) {
            pesBulls.forEach(bullet -> bullet.paintSelfImage(graphics));
            pesBulls.removeAll(delBulls);
            delBulls.clear();
        }
    }
}
